package com.platform.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.platform.comm.validation.groups.Insert;
import com.platform.comm.dto.AbstractQo;
import com.platform.comm.enums.YnEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * Description: 参数类别-DTO
 *
 * @author libin Created on 2019/7/18
 **/
@EqualsAndHashCode(callSuper = true)
@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class ConfTypeQo extends AbstractQo {
    private static final long serialVersionUID = -6056637343259993438L;
    /**
     * 父类别
     */
    private String parentId;

    /**
     * 类别编码
     */
    @NotEmpty(message = "类别编码不能为空", groups = Insert.class)
    @Size(max = 100, message = "类别编码长度不能超过100个字符")
    private String typeCode;

    /**
     * 类别名称
     */
    @NotEmpty(message = "类别名称不能为空", groups = Insert.class)
    @Size(max = 64, message = "类别名称长度不能超过64个字符")
    private String typeName;

    /**
     * 完整编码
     */
    @Size(max = 1024, message = "完整编码长度不能超过1024个字符")
    private String route;


    /**
     * 类别描述
     */
    @Size(max = 1024, message = "类别描述长度不能超过1024个字符")
    private String desc;

    /**
     * 类别层级
     */
    @JsonIgnore
    private Integer level;

    /**
     * 排序编号
     */
    private Integer sortNum;


    /**
     * 信息状态
     */
    @Pattern(regexp = "[01YN]", message = "信息状态不合法")
    private YnEnum delFlag;

    @Override
    public void init() {
        this.setDelFlag(YnEnum.N);
        if (this.getSortNum() == null) {
            this.setSortNum(0);
        }
    }
}
